package org.icop.utils;

import java.util.HashMap;
import java.util.Map;

import org.jbpt.algo.graph.DistanceRelation;
import org.jbpt.graph.abs.IDirectedEdge;
import org.jbpt.graph.abs.IDirectedGraph;
import org.jbpt.hypergraph.abs.IVertex;

public class GraphDistanceCache {

	private static GraphDistanceCache eInstance = null;
	
	public static GraphDistanceCache getInstance() {
		if (eInstance == null)
			eInstance = new GraphDistanceCache();
		
		return eInstance;
	}
	
	private Map<IDirectedGraph<IDirectedEdge<IVertex>, IVertex>, DistanceRelation<IDirectedEdge<IVertex>, IVertex>> distances = new HashMap<>();
	
	public DistanceRelation<IDirectedEdge<IVertex>, IVertex> getDistanceRelationForGraph(IDirectedGraph<IDirectedEdge<IVertex>, IVertex> g) {
		if (!this.distances.containsKey(g))
			this.distances.put(g,new DistanceRelation<IDirectedEdge<IVertex>, IVertex>(g));
		
		return this.distances.get(g);
	}
}
